import http from "@/utils/request";
import { type IRes } from "@/interFace/index";

interface IaddChat extends IRes {
  data:{
    chatId:number; // 聊天id
  }
}
 export interface IaddchatData {
  userId: string,
  type: number,
  assistantId?: number
}
// 提问助手  返回会话ID
export const addChat = (data: IaddchatData) => http.post<IaddChat>('/xlx-chat/chat/save',data)

export interface IChatList {
  userId:number
  type:string
  functionType?:number
  page?:number
  pageSize?:number
}

interface IchatListRes  extends IRes {
  data:{
    id: number; //回话ID
    userId: number;//用户ID
    created: string;//创建时间
    updated: string;
    question: string;//问题标题
    type: null
  }
}
// 查询会话列表
export const ChatList = (params: IchatListRes) => http.get<IchatListRes>('/xlx-chat/chat/list',params)

//删除会话
export const delChat = (ids:string)=>{
  return http.get('/xlx-chat/chat/delete',{ids})
}
//更改对话助手标题
export const updateChatId = (params: {id:string,question:string})=>{
  return http.post('/xlx-chat/chat/update', params)
}



interface IsendMessage extends IRes {
  data:{
    content: string;          // 答案
    contentType: string;      // 回复类型
    conversationId: string;   // 聊天对话唯一ID
    id: string;               // 聊天对话唯一ID
    parentMessageId: string;  // 回复对话ID
    role: string;           // 角色
  }
}
// 发送信息

export const sendMessage = (data:{
  id: string|number;
  userId: string|number;
  question: string;
})=>{
  return http.post<IsendMessage>('/xlx-chat/chatMessage/sendMessag', data)
}
//发送消息SSE模式
export const sendMessageSSE = (data: {
  id: string | number;
  userId: string | number;
  question: string;
}) => {
  return http.post<IsendMessage>('/xlx-chat/chatMessage/sendMessagSSE', data,{responseType: 'stream'})
}




export interface IgetChatMassageList extends IRes{
  data:{
    id: number, //聊天唯一ID
    createUser: string, //聊天人身份 1 2 用户  系统System
    createTime: string,//聊天时间
    chatId: number,//总的会话ID
    messageId: string; //聊天ID
    parentMessageId: '';//回复记录ID
    model: string;
    content: string,//聊天内容
    contentType: string; //内容格式
    role: string;//聊天角色  USER为用户本身  system为系统回答
    finishReason: string,
    status: number,// 聊天状态  1 回复中 2正常 3 失败
    usedTokens: 0
  }
}
// 聊天信息列表
export const getChatMassageList = (params:{
chatId:string;
page?:number;
pageSize?:number;
})=>{
  return http.get<IgetChatMassageList>('/xlx-chat/chatMessage/list',params)
}


// 面试记录
interface subLevelModel {
  id: number;
  years:string
}
interface IgetInterViewsList extends IRes {
  data:[
            {
            id: string; //身份ID
            name: string;//身份
            subLevelModelList: subLevelModel[]
        },
  ]
}

// 获取列表
export const getInterViewsList = ()=>{
  return http.get<IgetInterViewsList>('/xlx-chat/chat/interview/identityList')
}

export interface IsubLevelModelList {
  id: number;
  code:number;
  name:string;
  parentCode?:number;
  parentId?:number
  subLevelModelList?:IsubLevelModelList[]
}
interface IoccupationList extends IRes{
data:IsubLevelModelList[]
}
export const occupationList = ()=>{
  return http.get<IoccupationList>('/xlx-chat/chat/interview/occupationList')
}

// interview里面的内容
interface IconfirmIdentity{
chatId 	:string;
identity 	:string;
userId :string;
years :string;
post:string;
}
export const confirmIdentityAPI = (data: IconfirmIdentity)=>{
  return http.post('/xlx-chat/chat/interview/confirmIdentity', data)
}
interface IchatInfoData extends IRes{
 data:{
   id: number; //254,
   userId: number; //1,
   created: string;//2024-06-17 11:08:30,
   updated: string;//2024-06-17 11:12:30,
   question: string;//模拟面试,
   type: number; //2,
   assistantId: number; // 5,
   identity: string;//应届,//身份
   occupation: string;//技术美术,//职业  当职业为空时需要输入身份信息
   workTime: string;//"2年"//工作经验
 }
}
export  const chatInfoData =(id:string|number)=>{
  return http.get<IchatInfoData>('/xlx-chat/chat/get',{id})
}


export interface IAssistantItem {
  assistantId: number; // 助手ID
  createUser: string; // 创建人
  avatar: string;
  icon: string; // 图标
  title: string; // 标题
  tag: string; // 详细信息
  code: number; // 新建列表时 type 值
}


interface IproprammersList extends IRes {
  data:IAssistantItem[]
}
// 程序员
export const assistantList = ()=>{
  return http.get<IproprammersList>('/xlx-chat/assistant/list')
}
